<template>
    <div class="deposit">

        <!--S头-->
        <i-header @deposit-success="depositSuccess"></i-header>
        <!--E头-->

        <!--S提现列表-->
        <div id="list">
            <h3>提现列表</h3>
            <cube-scroll
                    ref="scroll"
                    v-if="data.length > 0"
                    :options="scroll_option"
                    @pulling-up="upLoad"
            >
                <item v-for="item in data"
                      :key="item.id"
                      :data="item"
                ></item>
            </cube-scroll>
            <empty v-else>暂无数据</empty>
        </div>
        <!--E提现列表-->

    </div>
</template>

<script>
//提现
import IHeader from "./components/header"
import Item from "./components/item"
import Empty from "@c/empty"
export default {
    name: "deposit",
    data() {
        return {
            data: [],
            limit: [0,20],
            // 滚动条配置
            scroll_option: {
                pullUpLoad:{
                    txt:{
                        more:"上拉加载",
                        noMore:"----我也是有底线的----"
                    }
                }
            },
            // 是否正在加载中
            loading: false
        }
    },
    components: {
        IHeader,
        Item,
        Empty
    },
    mounted() {
        this.getList()
    },
    methods: {
        /**
         * 获取列表
         */
        getList(){
            if(this.loading) return
            this.loading = true
            this.$get("deposit/getUserList",{
                limit: this.limit
            })
                .then((res) => {
                    this.loading = false
                    let {code, data} = res.data
                    if(code === 0) {
                        this.limit[0] += this.limit[1]
                        this.$refs.scroll && this.$refs.scroll.forceUpdate(true,false)
                        this.data.push(...data)
                    } else {
                        this.$refs.scroll && this.$refs.scroll.forceUpdate(true,true);
                    }
                })
        },
        /**
         *上拉加载
         */
        upLoad() {
            this.getList()
        },
        /**
         * 提现成功
         */
        depositSuccess() {
            this.limit = [0,20]
            this.data = []
            this.getList()
        }
    }
}
</script>

<style scoped lang="less" src="./deposit.less"></style>
